package org.example.user.service.storage;

import org.apache.ibatis.annotations.*;
import org.example.user.data.entity.UserEntity;

@Mapper
public interface UserEntityMapper {

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into t_user_entity(account, password, display_name, display_image, state, create_timestamp) value(#{account}, #{password}, #{displayName}, #{displayImage}, #{state}, #{createTimestamp})")
    public Integer insertUserEntity(UserEntity userEntity);

    @Select("select * from t_user_entity where id = #{id}")
    public UserEntity selectUserEntityById(Long id);

    @Select("select * from t_user_entity where account = #{account} and password = #{password}")
    public UserEntity selectByAccountAndPassword(@Param("account") String account, @Param("password")String password);

    @Update("update t_user_entity set display_name = #{displayName}, display_image = #{displayImage} where id = #{id}")
    public Integer updateUserEntity(UserEntity userEntity);

}
